#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
dnl AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_INIT([libqdxclient], 1.0.0, 'kuerant@gmail.com')
AC_CONFIG_SRCDIR([src/qdxc/connection.cpp])

dnl Setup library CURRENT, REVISION and AGE
LIBCUR=1
LIBREV=0
LIBAGE=0
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

dnl libtool-style version-info number
LIBVERSION=$LIBCUR:$LIBREV:$LIBAGE
AC_SUBST(LIBVERSION)

dnl AC_CONFIG_HEADER([config.h])
AC_CONFIG_HEADER([include/config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_LIBTOOL

# Checks for libraries.
# FIXME: Replace `main' with a function in `-lqsocket':
dnl AC_CHECK_LIB([qsocket], [main])

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T

# Checks for library functions.
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([gethostbyaddr gethostbyname inet_ntoa memmove memset select socket strerror])

# Check for SOL_IP
AC_MSG_CHECKING(for SOL_IP)
AC_TRY_COMPILE([
  #include <netdb.h>
  #include <sys/socket.h>
], [
  int level = SOL_IP;
], [
  AC_MSG_RESULT(yes)
  AC_DEFINE([HAVE_SOL_IP], [1], [Define to 1 if SOL_IP is defined.])
], [
  AC_MSG_RESULT(no)
])


AC_CONFIG_FILES([Makefile
                 src/Makefile
                 src/qdxc/Makefile
                 src/zsocket/Makefile
                 test/Makefile
                 test/func/Makefile
                 test/func/qdxc/Makefile
                 test/func/zsocket/Makefile
                ])
AC_OUTPUT
